﻿function yourGamesController($scope, $http) {
    
    $scope.collapseGame = function (game) {
        for (var i in $scope.game) {
            delete $scope.game[i].collapseGame;
        }
        if (game.collapseGame) {
            delete game.collapseGame;
        } else {
            game.collapseGame = true;
        };
    };

    $http.get("api/game/user/" + $scope.username).success(function (data) { 
        $scope.usergames = data;
    }).error(function (data) {
        console.log(JSON.stringify(data))
    });

    $scope.rentalReturn = function (rental) {
        rental.WasReturned = true;
        $http.put("api/rental/", rental).success(function (data) {
            console.log(data);
        }).error(function (data) {
            rental.WasReturned = false;
            console.log(JSON.stringify(data));
        });
    }
}